home *** CD-ROM | disk | FTP | other *** search
/ Super PC 28 / Super PC 28 (Shareware para Windows 95 y MS-DOS).iso / spc / util / inter45 / int2hlp / int2hm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-23  |  12.1 KB  |  391 lines

  1. /********************************
  2.  **                                   **
  3.  **  INT2HM.C                      **
  4.  **  (INT list TO HelpMake)    **
  5.  **                                   **
  6.  **  by Giorgio Caimi             **
  7.  **                                   **
  8.  ********************************/
  9.  
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #include <ctype.h>
  14.  
  15.  /* Formats definition */
  16.  
  17. char intlist[]=
  18. ".context h.title\nINTERRUPTS,PORTS,MEMORY and CMOS Help\n"
  19. ".context h.default\n.topic INTERRUPTS LIST (copyrights)\n\n\n\n"
  20. "               \\bINT2HM (INTerrupts list TO HelpMake converter)\\p\n"
  21. "                 \\bby GIORGIO CAIMI (caimi@zeus.csr.unibo.it)\\p\n\n\n"
  22. "       All documentation files except INTERRUPTS LIST, PORTS LIST and\n"
  23. "       CATEGORY LIST  are  copied  into  the  data-base  as  they are\n"
  24. "       provided,  copyrights  and other restrictions applied from the\n"
  25. "       authors are contained into their respective files.\n\n"
  26. "       Copyrights for INTERRUPTS LIST,  PORTS LIST  and CATEGORY LIST\n"
  27. "       belong  to the  respective authors;  copyright information had\n"
  28. "       to be  removed  from the  original files  due to  the indexing\n"
  29. "       process requirements.\n\n\n"
  30. "                                                                 "
  31. "\\u[\\u\\aOK\\vh.contents\\v\\u]\\u\n"
  32. ".context h.contents\n.topic INTERRUPTS LIST (files index)\n"
  33. "    \\u[\\u\\aINTERRUPTS\\vis\\v\\u]\\u"
  34. "  \\u[\\u\\aMEMORY\\vmt\\v\\u]\\u"
  35. "  \\u[\\u\\aPORTS\\vpi\\v\\u]\\u"
  36. "  \\u[\\u\\aCMOS\\vct\\v\\u]\\u"
  37. "                     \\u[\\u\\aBACK\\v!B\\v\\u]\\u\n"
  38. "  ──────────────────────────────────────────────────────────────────────\n\n"
  39. " ████ ██   ██ ██████ ███████ ██████  ██████  ██  ██ ██████  ██████  ████ \n"
  40. "  ██  ███  ██ █ ██ █  ██   █  ██  ██  ██  ██ ██  ██  ██  ██ █ ██ █ ██  ██\n"
  41. "  ██  ████ ██   ██    ██ █    ██  ██  ██  ██ ██  ██  ██  ██   ██   ███\n"
  42. "  ██  ██ ████   ██    ████    █████   █████  ██  ██  █████    ██    ███\n"
  43. "  ██  ██  ███   ██    ██ █    ██ ██   ██ ██  ██  ██  ██       ██      ███\n"
  44. "  ██  ██   ██   ██    ██   █  ██  ██  ██  ██ ██  ██  ██       ██   ██  ██\n"
  45. " ████ ██   ██  ████  ███████ ███  ██ ███  ██ ██████ ████     ████   ████\n\n"
  46.  
  47. "                       ████    ████  ████  ██████\n"
  48. "                        ██      ██  ██  ██ █ ██ █\n"
  49. "                        ██      ██  ███      ██\n"
  50. "                        ██      ██   ███     ██\n"
  51. "                        ██   █  ██     ███   ██\n"
  52. "                        ██  ██  ██  ██  ██   ██\n"
  53. "                       ███████ ████  ████   ████\n\n"
  54. "  ──────────────────────────────────────────────────────────────────────\n"
  55. "                                   HelpMake converter by Giorgio Caimi\n",
  56. mem[]=".context mt\n.topic MEMORY.LST\n",
  57. cmos[]=".context ct\n.topic CMOS.LST\n",
  58. gloss[]=".context gt\n.topic GLOSSARY.LST\n",
  59. keys[]=".context kt\n.topic CATEGORY.KEY\n",
  60. klink[]="  \\u\\aSEARCHING KEYS\\vkt\\v\\u\n\n",
  61. port[]=".context pi\n",
  62. port_a[]=".context pt####\n",
  63. port_b[]=".topic PORTS.LST\n",
  64. intlst[]=".context is\n",
  65. intlst_a[]=".context ii####\n",
  66. intlst_b[]=".context it####\n",
  67. intlst_c[]=".topic INTERRUP.LST\n",
  68. intlst_d[]="\\bCATEGORY :\\p ##\n\\bKEY      :\\p #"
  69. "                                                  ", /* filler[50] */
  70. line[]=
  71. "  ──────────────────────────────────────────────────────────────────────\n",
  72. menu[]=
  73. ".freeze 2\n"
  74. "    \\u[\\u\\aBACK\\v!B\\v\\u]\\u"
  75. "  \\u[\\u\\aFILES INDEX\\vh.contents\\v\\u]\\u"
  76. "                                 "
  77. "  \\u[\\u\\aGLOSSARY\\vgt\\v\\u]\\u\n",
  78. menuglo[]=
  79. ".freeze 2\n"
  80. "    \\u[\\u\\aBACK\\v!B\\v\\u]\\u"
  81. "  \\u[\\u\\aFILES INDEX\\vh.contents\\v\\u]\\u\n",
  82. menuglo1[]=
  83. ".freeze 2\n"
  84. "    \\u[\\u\\aFILES INDEX\\vh.contents\\v\\u]\\u"
  85. "                                         "
  86. "  \\u[\\u\\aGLOSSARY\\vgt\\v\\u]\\u\n",
  87. menubas[]=
  88. ".freeze 2\n"
  89. "    \\u[\\u\\aFILES INDEX\\vh.contents\\v\\u]\\u\n";
  90.  
  91. char *checkslash(char *str)
  92. /* converts backslash into double-backslash */
  93. {
  94.     int i,h;
  95.  
  96.     for (i=0;str[i];i++) {
  97.         if (str[i]=='\\') {
  98.             for (h=strlen(str)+1;h>i;h--) str[h]=str[h-1];
  99.             ++i;
  100.         }
  101.     }
  102.     return str;
  103. }
  104.  
  105. void main(void)
  106. {
  107.     FILE *fs,*fd,*fi;
  108.     char str[150],str1[150],str2[150],str3[10],str4[10],*error,hmfname[13];
  109.     unsigned cnt,cnt1;
  110.     int i,j,k,comp,intno,destno=0,ctxcont=0;
  111.  
  112.     printf("\n INT-list to HelpMake converter\n"
  113.                 " (c) 1994-95 by Giorgio Caimi\n\n"
  114.             "Checking archives...");
  115.     if ((fopen("PORTS.LST","rb")==NULL)||
  116.        (fopen("CMOS.LST","rb")==NULL)||
  117.          (fopen("MEMORY.LST","rb")==NULL)||
  118.          (fopen("GLOSSARY.LST","rb")==NULL)||
  119.          (fopen("CATEGORY.KEY","rb")==NULL)) {
  120.       fcloseall();
  121.         printf("NEED 'PORTS.LST','MEMORY.LST','CMOS.LST',\n"
  122.                  "                         "
  123.                  "'GLOSSARY.LST' AND 'CATEGORY.KEY'\n");
  124.         putchar(7);
  125.       exit(1);
  126.    }
  127.    fcloseall();
  128.  
  129.     if (fopen("INTERRUP.LST","rb")==NULL) {
  130.        fcloseall();
  131.         printf("RUN 'COMBINE.BAT' FIRST\n");
  132.         putchar(7);
  133.       exit(2);
  134.     }
  135.     fcloseall();
  136.  
  137.     printf("OK\nWriting banner...");
  138.  
  139.    sprintf(hmfname,"INTLST%02X.HM",++destno);
  140.     fd=fopen(hmfname,"wt");
  141.     fputs(intlist,fd);
  142.  
  143.     printf("OK\nConverting 'MEMORY.LST'...");
  144.     fs=fopen("MEMORY.LST","rt");
  145.     fputs(mem,fd); /* put context */
  146.     fputs(menuglo1,fd); /* put menu */
  147.    fputs(line,fd);
  148.     while (fgets(str,95,fs)) fputs(checkslash(str),fd);
  149.     fclose(fs);
  150.  
  151.     printf("OK\nConverting 'CMOS.LST'...");
  152.     fs=fopen("CMOS.LST","rt");
  153.     fputs(cmos,fd); /* put context */
  154.     fputs(menuglo1,fd); /* put menu */
  155.    fputs(line,fd);
  156.     while (fgets(str,95,fs)) fputs(checkslash(str),fd);
  157.     fclose(fs);
  158.  
  159.     printf("OK\nConverting 'GLOSSARY.LST'...");
  160.     fs=fopen("GLOSSARY.LST","rt");
  161.     fputs(gloss,fd); /* put context */
  162.     fputs(menuglo,fd); /* put menu */
  163.    fputs(line,fd);
  164.     while (fgets(str,95,fs)) fputs(checkslash(str),fd);
  165.     fclose(fs);
  166.  
  167.    printf("OK\nConverting 'PORTS.LST'...");
  168.     fs=fopen("PORTS.LST","rt");
  169.     fi=fopen("PORTS.IDX","wt");
  170.     cnt=0;str2[0]='\0';
  171.     do {
  172.         do {
  173.             while (str2[0]!='-')
  174.                 fgets(str2,95,fs);
  175.             comp=strncmp(str2,"-------------CREDITS",20);
  176.             fgets(str2,95,fs);
  177.         } while ((str2[0]=='\n')&&(comp));
  178.         if (comp) {
  179.  
  180.          strcpy(str,str2);
  181.          str2[0]='\0';  /* topic formatting */
  182.          i=j=0;
  183.          while (str[i]&&(str[i]!=' ')&&(str[i]!='\t')) {
  184.             str2[j]=str[i];
  185.             ++i;
  186.             if (toupper(str2[j])!='H') ++j;
  187.          }
  188.          for (;j<10;j++) str2[j]=' ';
  189.          while ((str[i]==' ')||(str[i]=='\t')) i++;
  190.          if (((str[i]=='r')||(str[i]=='w'))&&
  191.              ((str[i+1]==' ')||(str[i+1]=='\t')||(str[i+1]=='/')))
  192.             for (;(str[i]!=' ')&&(str[i]!='\t');i++) str2[j++]=str[i];
  193.          else while (str[i]=='-') i++;
  194.          while ((str[i]==' ')||(str[i]=='\t')) ++i;
  195.          for (;j<14;j++) str2[j]=' ';
  196.          if (str2[j-1]!=' ') str2[j++]=' ';
  197.          for (;str[i];i++) {
  198.             str2[j]=str[i];
  199.             if (str2[j]=='\t') str2[j]=' ';
  200.             ++j;
  201.          }
  202.          str2[j]='\0';
  203.          checkslash(str2);
  204.  
  205.          fputs(str2,fi);   /* add entry to index */
  206.             fgets(str,95,fs);
  207.             if (!strcmp(str,"\n")) fgets(str,95,fs); /* search text */
  208.             if (str[0]!='-') {  /* Is there any description? */
  209.                 sprintf(str1,"%04u\n",cnt++);
  210.                 strncpy(port_a+11,str1,4);
  211.             fputs(port_a,fd);fputs(port_b,fd);/* put context */
  212.                 fputs(menu,fd);fputs(line,fd); /* put menu */
  213.                 fputs("\\b",fd); /* bold on */
  214.                 str2[strlen(str2)-1]='\0';fputs(str2,fd);
  215.                 fputs("\\p\n\n",fd); /* bold off */
  216.                 do fputs(checkslash(str),fd); while (fgets(str,95,fs),*str!='-');
  217.                 fputs(str1,fi);
  218.                 ++ctxcont;
  219.             } else fputs("\n",fi);
  220.          strcpy(str2,str);
  221.         }
  222.     } while (comp);
  223.     fclose(fi);fclose(fs);
  224.  
  225.     printf("OK\nIndexing 'PORTS.LST'...");
  226.     fs=fopen("PORTS.IDX","rt");
  227.    fputs(port,fd);fputs(port_b,fd);
  228.     fputs(menubas,fd);fputs(line,fd);
  229.     while (fgets(str,95,fs)) {
  230.         fgets(str1,95,fs);
  231.         if ((k=strcmp(str1,"\n"))!=0) fputs("\\u\\a",fd);
  232.       str[strlen(str)-1]='\0';  /* del newline */
  233.         fputs(str,fd);
  234.       if (k) {
  235.             fputs("\\v",fd);
  236.             strncpy(port_a+11,str1,4);
  237.             strcpy(str1,port_a+9);
  238.             str1[strlen(str1)-1]='\0';
  239.             fputs(str1,fd);
  240.             fputs("\\v\\u",fd);
  241.             ++ctxcont;
  242.       }
  243.       putc('\n',fd);
  244.     }
  245.    fclose(fs);
  246.    unlink("PORTS.IDX");
  247.  
  248.     printf("OK\nConverting 'CATEGORY.KEY'...");
  249.     fs=fopen("CATEGORY.KEY","rt");
  250.     fputs(keys,fd); /* put context */
  251.     fputs(menuglo,fd); /* put menu */
  252.    fputs(line,fd);
  253.     while (*fgets(str,95,fs)!='-') ;
  254.    while (fgets(str,95,fs)) {
  255.       error=str;
  256.       while ((*error=='\t')||(*error==' ')) ++error;
  257.       fputs(checkslash(error),fd);
  258.    }
  259.     fclose(fs);
  260.  
  261.     printf("OK\nConverting 'INTERRUP.LST'...");
  262.     fs=fopen("INTERRUP.LST","rt");
  263.     fi=fopen("INTERRUP.IDX","wt");
  264.     cnt=cnt1=str[0]=0;intno=-1;
  265.     do {
  266.         do {
  267.             strcpy(str2,str);
  268.           while (strncmp(str2,"--------",8))
  269.                 fgets(str2,95,fs);
  270.             comp=strncmp(str2,"--------!---Admin",17);
  271.             if ((comp)&&(str2[8]=='!')) fgets(str,95,fs);
  272.         } while ((comp)&&(str2[8]=='!'));
  273.         if (comp) {
  274.             intlst_d[15]=str2[8]; /* category (main) */
  275.             i=10;j=33;
  276.             for (;str2[i];i++) {  /* key */
  277.                 intlst_d[j]=str2[i];
  278.                 if (intlst_d[j]!='-') ++j;
  279.             }
  280.             intlst_d[j]='\0';
  281.             str[0]=str2[10];str[1]=str2[11]; /* int no. */
  282.             str[2]='\0';
  283.             k=(int)strtol(str,&error,16);
  284.             if ((k!=intno)||(cnt1==500)) {
  285.             if (intno>=0) fputs("\n\n",fi);
  286.             fputs(str,fi);  /* put int no. */
  287.                 putc('\n',fi);
  288.                 intno=k;cnt1=0;
  289.             } else ++cnt1;
  290.             fgets(str2,95,fs);
  291.             intlst_d[16]=str2[7]; /* category (flag) */
  292.             if (str2[7]=='-') i=9; else i=11;
  293.             strcpy(str,str2+i); /* description */
  294.             checkslash(str);
  295.             sprintf(str1,"%04u\n",cnt++);
  296.          fputs(str,fi);fputs(str1,fi);
  297.             strncpy(intlst_b+11,str1,5);
  298.             fputs(intlst_b,fd);fputs(intlst_c,fd);/* put context */
  299.             fputs(menu,fd);fputs(line,fd); /* put menu */
  300.             fputs("\\b",fd); /* bold on */
  301.             str[strlen(str)-1]='\0';fputs(str,fd);
  302.             fputs("\\p\n",fd); /* bold off */
  303.             fputs(intlst_d,fd);
  304.             putc('\n',fd);
  305.             while (fgets(str2,95,fs),strncmp(str2,"--------",8))
  306.                 fputs(checkslash(str2),fd);
  307.             strcpy(str,str2);
  308.             ++ctxcont;
  309.             if (ctxcont==600) {
  310.                 ctxcont=0;
  311.             sprintf(hmfname,"INTLST%02X.HM",++destno);
  312.                 freopen(hmfname,"wt",fd);
  313.             }
  314.         }
  315.     } while (comp);
  316.    fputs("\n\n",fi);
  317.     fclose(fi);fclose(fs);
  318.  
  319.     printf("OK\nIndexing 'INTERRUP.LST'...");
  320.     fs=fopen("INTERRUP.IDX","rt");
  321.     fi=fopen("INTERRUP.CNT","wb");
  322.     fputs(intlst,fd);fputs(intlst_c,fd); /* put context */
  323.    fputs(menubas,fd);fputs(line,fd); /* put menu */
  324.    fputs(klink,fd); /* put searching keys link */
  325.    cnt=0;
  326.    while (fgets(str,95,fs)) {
  327.         str3[0]=str1[0]=cnt1=0;
  328.         do {
  329.             strcpy(str4,str3);
  330.          fgets(str1,95,fs);
  331.             fgets(str3,9,fs);
  332.             ++cnt1;
  333.         } while (*str1!='\n');
  334.         fputs("  \\u\\aINT ",fd);
  335.         str[strlen(str)-1]='\0';  /* del newline */
  336.         fputs(str,fd);
  337.         fputs("\\v",fd);
  338.         if (cnt1==2) { /* put text */
  339.             strncpy(intlst_b+11,str4,5);
  340.             strcpy(str1,intlst_b+9);
  341.         } else { /* put index */
  342.             sprintf(str4,"%04u",cnt++);
  343.             strncpy(intlst_a+11,str4,4);
  344.             strcpy(str1,intlst_a+9);
  345.         }
  346.       str1[strlen(str1)-1]='\0';
  347.         fputs(str1,fd);
  348.         putw(cnt1-1,fi);
  349.         fputs("\\v\\u\n",fd);
  350.     }
  351.     fclose(fs);fclose(fi);
  352.  
  353.    fs=fopen("INTERRUP.IDX","rt");
  354.     fi=fopen("INTERRUP.CNT","rb");
  355.     cnt=0;
  356.     while ((k=getw(fi))!=EOF) {
  357.         fgets(str,95,fs);
  358.         if (k>1) {
  359.             sprintf(str3,"%04u",cnt++);
  360.             strncpy(intlst_a+11,str3,4);
  361.             fputs(intlst_a,fd);fputs(intlst_c,fd); /* put context */
  362.             fputs(menu,fd);fputs(line,fd); /* put menu */
  363.         }
  364.         for (i=0;i<k;i++) {
  365.             fgets(str,95,fs);
  366.          fgets(str3,9,fs);
  367.             if (k>1) {
  368.                 fputs("\\u\\a",fd);
  369.                 str[strlen(str)-1]='\0';  /* del newline */
  370.                 fputs(str,fd);
  371.                 fputs("\\v",fd);
  372.                 strncpy(intlst_b+11,str3,5);
  373.                 strcpy(str1,intlst_b+9);
  374.                 str1[strlen(str1)-1]='\0';  /* del newline */
  375.                 fputs(str1,fd);
  376.             fputs("\\v\\u\n",fd);
  377.             }
  378.         }
  379.       fgets(str3,9,fs);
  380.         fgets(str3,9,fs);
  381.     }
  382.  
  383.     fclose(fs);fclose(fi);
  384.     unlink("INTERRUP.IDX");unlink("INTERRUP.CNT");
  385.  
  386.    fclose(fd);
  387.  
  388.     printf("OK\n\nDONE.\n");
  389.     putchar(7);
  390. }
  391.